package com.evola.dbsm.view.project.list
{
	import com.evola.dbsm.communication.Commands;
	import com.evola.dbsm.model.ProjectBean;
	import com.evola.dbsm.service.RemoteServiceFacade;
	import com.evola.dbsm.service.ServiceResult;
	import com.evola.dbsm.utils.MockDataSource;
	import com.evola.dbsm.view.navigation.NavigationPresenter;
	import com.evola.dbsm.view.script.list.ScriptListModel;
	
	import flash.events.MouseEvent;
	
	import mx.collections.IList;
	import mx.events.FlexEvent;

	[Bindable]
	public class ProjectListPresenter 
	{

		public var model:ProjectListModel = new ProjectListModel();
		public var view:ProjectListView;

		public function ProjectListPresenter() {
			
		}

		public function init() : void{
			
			RemoteServiceFacade.executeCommand(Commands.FIND_ALL_OBJECTS_COMMAND, new ProjectBean(), onProjectsLoaded);
		}
		
		private function onProjectsLoaded(result : ServiceResult) : void{
			
			var projects : IList = result.data as IList;

			model.projects = projects;
		}
		
		public function addProject() : void{
			
			
		}
		
		public function selectProject(project : ProjectBean) : void{
			
			Presenters.navigationPresenter.showProject(project);
		}
		
	}
}